<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
     div{
      position: absolute;
     }
     p{
      position: absolute;
      top:30px
     }
  </style>
</head>
<body>
   <div>动画1</div>
   <br />
   <div>动画2</div>

   
  <p>动画1</p>
</body>
<script>
   const divDom = document.querySelectorAll("div")
   const pDom = document.querySelectorAll("p")
    divDom.forEach(item => {
      let left = 1
      item.addEventListener("click", function () {
          console.log(left,651000);
          setInterval(() => {
            left++
            this.style.left = left + "px"
          }, 10);
      })
    })
    pDom.forEach(item => {
        let flag=false
        item.addEventListener("click", function () {
          if(!flag){
            let left = 1
            //flag = true
            flag=setInterval(() => {
              left++
              this.style.left = left + "px"
            }, 100);
          }
          
        })
      })
</script>
</html>